"""
n, m = map(int, input().split())
ls = [0] * (m+1)
lt = []
for i in range(n):
    l = list(map(int, input().split()))
    l.remove(l[0])
    lt += l
    for j in range(1, m+1):
        if l.count(j) > 0:
            ls[j] += 1
for t in range(1, m+1):
    print(ls[t], lt.count(t), sep=' ')
"""

"""
# 集合: 集合是无序可变，元素不能重复。
# 使用{}创建集合对象，并使用add()方法添加元素
a = {3, 5, 7}
a.add(9)  # {9, 3, 5, 7}

# 使用set()，将列表、元组等可迭代对象转成集合。
# 如果原来数据存在重复数据，则只保留一个
a = ['a', 'b', 'c', 'b']
b = set(a)  # {'b','a','c'}

# remove()删除指定元素；clear()清空整个集合
a = {10, 20, 30, 40, 50}
a.remove(20)  # {10, 50, 40,30}

a = {1, 3, 'sxt'}
b = {'he', 'it', 'sxt'}
print(a | b)  # 并集
print(a & b)  # 交集
print(a - b)  # 差集
print(a ^ b)  # 对称差集
"""


n, m = map(int, input().split())
l1 = map(str, input().upper().split())
l2 = map(str, input().upper().split())
a1 = set(l1)
a2 = set(l2)
b = a1 & a2
print(len(b))
print(len(a1)+len(a2)-len(b))



# print(max([{4}, {1}, {2}, {3}]))

"""
l = []
for i in range(100, 1000):
    j = str(i)
    if int(j[0]) ** 3 + int(j[1]) ** 3 + int(j[2]) ** 3 == i:
        l.append(i)

print(','.join(map(str, l)))
"""

"""
class Banji:
    num = 0

    @classmethod
    def addNum(cls):
        cls.num += 1

    @classmethod
    def getNum(cls):
        return cls.num

    def __new__(cls, student_total):
        Banji.addNum()
        return object.__new__(cls)


class Student(Banji):
    def __init__(self, name):
        self.name = name


s1 = Student('小王')
s2 = Student('小张')
print(Banji.getNum())
"""

